home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games: Greatest Hits 1996 / Amiga Games: Greatest Hits 1996.iso / spiele / publicdomain / scott / source / source.lha / ansi.c < prev    next >
C/C++ Source or Header  |  1996-07-28  |  2KB  |  85 lines

  1. /*
  2.  *  ANSI commands (some AMIGA specific) for Scott-Free, Write to CON:
  3.  *
  4.  *  ===================================================================
  5.  *
  6.  *  Version History AMIGA:
  7.  *  Ver ,     Date,         Author, Comment
  8.  *  -------------------------------------------------------------------
  9.  *  1.0 , 28/07/96, Andreas Aumayr, First public release
  10.  *  ___________________________________________________________________
  11.  */
  12.  
  13.  
  14. #include <dos/stdio.h>
  15. #include <libraries/dos.h>
  16.  
  17. #define ESC         "\x1b"
  18. #define CSI         ESC "["
  19. #define CLREOL      CSI "K""\0"
  20. #define CLRSCR      "\x0c""\0"
  21. #define CLRSYS      ESC "c""\0"
  22. #define CURSOR_ON   CSI " p""\0"
  23. #define CURSOR_OFF  CSI "0 p""\0"
  24. #define DEF_TXTCOL  CSI "39;49m""\0"
  25. #define DEL_CHAR    CSI "P"
  26. #define AUTO_WRAP   CSI "?7""\0"
  27. #define AUTO_SCRL   CSI ">1""\0"
  28.  
  29. #define GREY        0
  30. #define BLACK       1
  31. #define WHITE       2
  32. #define BLUE        3
  33.  
  34. char str_buf[1024];
  35.  
  36. struct FileHandle *CON_handle,*act_hdl=NULL,*env_hdl=NULL;
  37.  
  38. void WriteCON(char *string)
  39. {
  40.     Write(CON_handle,string,strlen(string));
  41. }
  42.  
  43. void cursor(BOOL action)
  44. {
  45.     if (action) WriteCON(CURSOR_ON);
  46.     else WriteCON(CURSOR_OFF);
  47. }
  48.  
  49. void clrsys(void)
  50. {
  51.     WriteCON(CLRSYS);
  52.     //WriteCON(AUTO_WRAP);
  53.     //WriteCON(AUTO_SCRL);
  54. }
  55.  
  56. void clrscr(void)
  57. {
  58.     WriteCON(CLRSCR);
  59. }
  60.  
  61. void clreol(void)
  62. {
  63.     WriteCON(CLREOL);
  64.  
  65. }
  66.  
  67. void textcolor(int fg, int bg)
  68. {
  69.     sprintf(str_buf,CSI"0;%d;%dm\0",fg+30,bg+40);
  70.     WriteCON(str_buf);
  71. }
  72.  
  73. void background(int color)
  74. {
  75.     sprintf(str_buf,CSI">%dm\0",color);
  76.     WriteCON(str_buf);
  77. }
  78.  
  79. void gotoxy(int x, int y)
  80. {
  81.     sprintf(str_buf,CSI"%d;%dH\0",y,x);
  82.     WriteCON(str_buf);
  83. }
  84.  
  85.